from tkinter import *
import  database as up
class Update:
    def __init__(self):
        root = Tk()
        root.title('修改学生信息')
        Label(root, text='学号:').grid(row=0)
        Label(root, text='姓名:').grid(row=1)
        Label(root, text='C语言:').grid(row=2)
        Label(root, text='java:').grid(row=3)
        Label(root, text='python:').grid(row=4)
        Label(root, text='总分:').grid(row=5)
        Label(root, text='加权平均分:').grid(row=6)

        id = Entry(root, textvariable=StringVar())
        name = Entry(root, textvariable=StringVar())
        Clanguage = Entry(root, textvariable=StringVar())
        java = Entry(root, textvariable=StringVar())
        python = Entry(root, textvariable=StringVar())
        Totalscore = Entry(root, textvariable=StringVar())
        average = Entry(root, textvariable=StringVar())

        id.grid(row=0, column=1, padx=10, pady=10)
        name.grid(row=1, column=1, padx=10, pady=5)
        Clanguage.grid(row=2, column=1, padx=10, pady=5)
        java.grid(row=3, column=1, padx=10, pady=5)
        python.grid(row=4, column=1, padx=10, pady=5)
        Totalscore.grid(row=5, column=1, padx=10, pady=5)
        average.grid(row=6, column=1, padx=10, pady=5)

        def Up():
            sid = int(id.get())
            sname = name.get()
            sClanguage = int(Clanguage.get())
            sjava = java.get()
            spython = python.get()
            sTotalscore = int(Totalscore.get())
            saverage = average.get()

            up.Update(sid, sname, sClanguage, sjava, spython, sTotalscore, saverage)

            id.delete(0, END)
            name.delete(0, END)
            Clanguage.delete(0, END)
            java.delete(0, END)
            python.delete(0, END)
            Totalscore.delete(0, END)
            average.delete(0, END)

        Button(root, text='修改', width=10, command=Up).grid(row=7, column=0, sticky=W, padx=10, pady=5)
        Button(root, text='取消', width=10,command=root.quit).grid(row=7, column=1, sticky=E, padx=10, pady=5)
        mainloop()

if __name__ == '__main__':
    Update()
